<div class="row-content am-cf">
	<div class="row">
		<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
			<div class="widget am-cf">
				<div class="widget-head am-cf">
					<div class="widget-title am-fl">编辑用户</div>
					<div class="widget-function am-fr">
						<a href="javascript:;" class="am-icon-cog"></a>
					</div>
				</div>
				<div class="widget-body am-fr">
					<form class="am-form tpl-form-line-form" id="dataForm" method="post">
						<input type="hidden"  name="id" th:value="${user.id}" required="required"/> 	
						<div class="am-form-group">
							<label for="descs" class="am-u-sm-2 am-form-label">头像
								<span class="tpl-form-line-small-title">HeadImg</span>
							</label>
							<div class="am-u-sm-10">
								<input id="upFile" type="file"  />
								<input id="coverImg" type="hidden"  name="img" th:value="${user.img}"/>
							</div>
						</div>
						<div class="am-form-group">
							<label for="name" class="am-u-sm-2 am-form-label">姓名
								<span class="tpl-form-line-small-title">Name</span>
							</label>
							<div class="am-u-sm-10">
								<input type="text" id="name" class="tpl-form-input" placeholder="请输入姓名" name="userName" th:value="${user.userName}" required="required"/>
							</div>
						</div>

						<div class="am-form-group">
							<label for="role" class="am-u-sm-2 am-form-label">邮箱
								<span class="tpl-form-line-small-title">Email</span>
							</label>
							<div class="am-u-sm-10">
								<input type="text" id="email" class="tpl-form-input" placeholder="请输入邮箱" name="email" th:value="${user.email}" required="required"/>
							</div>
						</div>

						<div class="am-form-group">
							<label for="desc" class="am-u-sm-2 am-form-label">用户描述 <span
								class="tpl-form-line-small-title">Desc</span></label>
							<div class="am-u-sm-10">
								<input type="text" id="desc" name="description" th:value="${user.description}" placeholder="请输入用户描述"/>
							</div>
						</div>

						<div class="am-form-group">
							<div class="am-u-sm-10 am-u-sm-push-2">
								
								<button type="button" onclick="javascript:$('#dataForm').submit();"
									class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
										<button type="button" onclick="loadPage('user/listUI')"
									class="am-btn am-btn-success tpl-btn-bg-color-success ">返回</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>

	</div>
	<script th:inline="javascript">
	<![CDATA[
		var initImg = [];
		var img = [[${user.img != null?user.img:''}]];

		if(img!=''){
			initImg.push("<img height='160px' src='" + img + "' class='file-preview-image' alt='' title=''>");
		}
		initUpFileOne('upFile','coverImg','添加封面图片',initImg);
		
	validateUserForm();
	openDeptTree();
	function validateUserForm(){    
	    $('#dataForm').validate({
	        errorElement : 'span',
	        errorClass : 'am-icon-times',
	        focusInvalid : true,
	        onkeyup:false,
	        ignore : "",
	        rules : {
	            
	        	userName : {
	                required : true
	            }
	        },
	        messages : {
	        	userName : {
	                required : "请填写姓名"
	            }
	        },
	        submitHandler : function(form) {
	        	   var index;
	        	    var data = $("#dataForm").serialize();
	        	    $.ajax({
	        	        type : "POST",
	        	        url : "user/info",
	        	        data : data,
	        	        beforeSend : function() {
	        	            index = layer.load();
	        	        },
	        	        success : function(resultdata) {
	        	        	console.log(resultdata);
	        	            layer.close(index);
	        	            if (resultdata.status=="0") {
	        	                layer.msg(resultdata.message, {
	        	                    icon : 1
	        	                });
	        	                location.reload();
	        	            } else {
	        	                layer.msg(resultdata.message, {
	        	                    icon : 5
	        	                });
	        	            }
	        	        },
	        	        error : function(data, errorMsg) {
	        	            layer.close(index);
	        	            layer.msg(data.responseText, {
	        	                icon : 2
	        	            });
	        	        }
	        	    });
	        }
	    });
	}
		]]>
	</script>